#pragma once
#include "Common.h"

// 单例模式
class CentralCache
{
private:
	SpanList _spanLists[NFREELIST];					//hash桶
	static CentralCache _sInst;						//单例
	CentralCache() {}
	CentralCache(const CentralCache&) = delete;

public:
	static CentralCache* GetInstance() { return &_sInst; }

	// 获取一个非空的span
	Span* GetOneSpan(SpanList& list, size_t byte_size);

	// 获取一定数量的小块内存给ThreadCache
	size_t FetchRangeObj(void*& start, void*& end, size_t batchNum, size_t size);

	// 还一部分的小块内存给CentralCache
	void ReleaseListToSpans(void* start, size_t byte_size);

};